package com.derbysoft.dswitch.adapter.ihg.dswitch2.service.impl;

import com.derbysoft.remote.dswitch.generic.constants.UniqueIDType;
import com.derbysoft.remote.dswitch.hotel.dto.HotelReservationIDDTO;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.collections.Predicate;

import java.util.List;

public abstract class ReservationIDUtils {

    public static HotelReservationIDDTO getReservationID(List<HotelReservationIDDTO> reservationIDs, final UniqueIDType idType) {
        return (HotelReservationIDDTO) CollectionUtils.find(
                reservationIDs,
                new Predicate() {
                    public boolean evaluate(Object obj) {
                        return ((HotelReservationIDDTO) obj).getResIDType() == idType;
                    }
                }
        );
    }

    public static HotelReservationIDDTO getErspNo(List<HotelReservationIDDTO> reservationIDs) {
        return getReservationID(reservationIDs, UniqueIDType.ERSP);
    }

    public static HotelReservationIDDTO getHotelReservationNo(List<HotelReservationIDDTO> reservationIDs) {
        return getReservationID(reservationIDs, UniqueIDType.HOTEL);
    }

}
